package com.radiant.data.entity;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.google.inject.Inject;

@XmlRootElement
public class PostLike extends Like {
	
	@Inject 
	private PostDAO postDAO;
	
	@XmlTransient
	private Post post;
	
	public PostLike() {
		super(); 
	}

	public PostLike(Post post) {
		this.post = post;
	}

	@Override
	protected void setParentFromString(String parent) {
		this.post = postDAO.findByPrimaryKey(parent, true);
	}

	@Override
	protected String getParentAsString() {
		return post.getPostId();
	}

	@Override
	public void addToActivity(Activity activity) {
		activity.setPost(post);
	}

	@Override
	public void addMessageToActivity(Activity activity, User creator, Child child) {
		StringBuffer sb = new StringBuffer();
		sb.append(creator.getUserName()).append(" liked ");
		sb.append("post owner's").append("post");
		activity.setMessage(sb.toString());
	}

	
}
